// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import VueResource from 'vue-resource'

// 第三方框架和插件
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import 'font-awesome/css/font-awesome.min.css'
import VDistpicker from 'v-distpicker'

// 加载base64图片
import './imgBase64'
import './indeximgBase64'
import './lbtimgBase64'

// Vue.config.productionTip = false

import './common'

Vue.use(VueResource)
Vue.use(ElementUI)
Vue.component('v-distpicker', VDistpicker)

router.beforeEach((to, from, next) => {
  if (to.path === '/') {
    if (localStorage.xtoken !== undefined) {
      next({path: '/home'})
    } else {
      next()
    }
  } else {
    next()
  }
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: { App },
  render: h => h(App)
})
